package com.sssp.repository;

import com.sssp.entities.Department;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;

import javax.persistence.QueryHint;
import java.util.List;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/11/2 14:35
 */
public interface DepartmentRepository extends JpaRepository<Department, Integer> {

    /**
     * 使用自定义的方式显示配置JPA使用二级缓存
     *
     * @return
     */
    @QueryHints(@QueryHint(name = org.hibernate.jpa.QueryHints.HINT_CACHEABLE, value = "true"))
    @Query("from Department d")
    List<Department> getAll();
}
